#!/bin/bash
checkweb(){
  timeout=5
  fails=0
  success=0

  while true
    do
      wget --timeout=${timeout} --tries=1 http://192.168.121.135:8083 -q -O /dev/null
      if [ $? -ne 0 ]
        then 
          let fails=fails+1
      else
          let success=success+1
      fi
      if [ $success -ge 1 ]
	then
          echo 'web is OK!'
	  exit 0
      fi 
      if [ $fails -ge 2 ]
	then 
	  echo 'web is failed!'
          exit 2
      fi
    done			 
}
checkweb
